﻿using System.ComponentModel;
using System.Xml.Serialization;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Tomahawk.Resources.Materials;

namespace Tomahawk.Processors
{
    [ContentProcessor(DisplayName = "Material Processor - Tomahawk Engine")]
    public class MaterialContentProcessor : ContentProcessor<SASEffectCollection, SASEffectCollection>
    {
        protected string name;

        [DisplayName("Name")]
        [DefaultValue("Undefined")]
        [Description("Name of the actor")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public override SASEffectCollection Process(SASEffectCollection input, ContentProcessorContext context)
        {
            input.name = name;
            return input;
        }
    }

    [ContentTypeWriter]
    public class MaterialWriter : ContentTypeWriter<SASEffectCollection>
    {
        protected override void Write(ContentWriter output, SASEffectCollection value)
        {
            XmlSerializer x = new XmlSerializer(typeof(SASEffectCollection));
            x.Serialize(output.BaseStream, value);
        }
        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return typeof(SASEffectCollection).AssemblyQualifiedName;
        }
        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return "Tomahawk.Resources.Materials.MaterialReader, " +
                "Tomahawk.Resources, Version=1.0.0.0, Culture=neutral";
        }
    }
}